
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Text;

using Awaken.CodeGen                                                                                      .Entities;
using NUnit.Framework;

namespace Awaken.CodeGen.Entities.Tests.Generated
{
    [TestFixture]
    public class ProjectGeneratedFixture
    {
        [Test]
        public void VerifyGetAll()
        {
            IList list = Project.Broker.GetAll();
            Assert.IsNotNull(list);
        }
        
        [Test]
        public void VerifyOneToManys()
        {
            IList list = Project.Broker.GetAll();
            if( list.Count==0 )
            {
                Assert.Ignore("No Data");
                return;
            }
            
            Project obj = (Project)list[0];
            Assert.IsNotNull(obj);
            
            
        }
        
        [Test]
        public void VerifySelectOne()
        {
            string sql = "SELECT TOP 1 * FROM Project";
            
            OleDbConnection conn = new OleDbConnection("Provider=sqloledb;Data Source=(local);Initial Catalog=Awaken;Integrated Security=SSPI;");

            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;

            OleDbDataAdapter ada = new OleDbDataAdapter(cmd);
                        
            DataSet ds = new DataSet();
            
            conn.Open();
            ada.Fill(ds);
            conn.Close();
            
            if( ds.Tables[0].Rows.Count==0 )
            {
                Assert.Ignore("No Data");
            }
            else
            {
                object id = ds.Tables[0].Rows[0][0];
                Project obj = (Project)Project.Broker.GetByID( id );
                Assert.IsNotNull(obj);
            }
        }
    }
}
